package com.hzncc.flowable_diboot.dto;

import com.diboot.core.binding.query.BindQuery;
import com.diboot.core.binding.query.Comparison;
import com.diboot.iam.entity.IamOrg;
import com.diboot.iam.entity.IamUser;
import com.hzncc.flowable_diboot.entity.CustomerSeas;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

import com.hzncc.flowable_diboot.entity.Customer;

/**
 * 客户公海 DTO定义
 *
 * @author MyName
 * @version 1.0
 * @date 2024-05-15
 * Copyright © MyCorp
 */
@Getter
@Setter
@Accessors(chain = true)
public class CustomerSeasDTO extends CustomerSeas {
    private static final long serialVersionUID = 1562195629385999319L;

    /**
     * 进入公海天数 起始
     */
    @BindQuery(comparison = Comparison.GE, column = "enter_days")
    private Long enterDaysBegin;

    /**
     * 进入公海天数 截止
     */
    @BindQuery(comparison = Comparison.LE, column = "enter_days")
    private Long enterDaysEnd;
    /**
     * SAP客户编码 关联信息
     */
    @BindQuery(entity = Customer.class, column = "sn", condition = "this.name = id")
    private String sn;
    /**
     * 客户来源 关联信息
     */
    @BindQuery(entity = Customer.class, column = "source", condition = "this.name = id")
    private String source;
    /**
     * 客户级别 关联信息
     */
    @BindQuery(entity = Customer.class, column = "rank", condition = "this.name = id")
    private String rank;
    /**
     * 客户行业 关联信息
     */
    @BindQuery(entity = Customer.class, column = "business", condition = "this.name = id")
    private String business;
    /**
     * 客户标签 关联信息
     */
    @BindQuery(entity = Customer.class, column = "label", condition = "this.name = id")
    private String label;
    /**
     * 最后跟进时间 关联信息
     */
    @BindQuery(entity = Customer.class, column = "lastFollwUpTime", condition = "this.name = id")
    private String lastFollowTime;
    /**
     * 详细地址 关联信息
     */
    @BindQuery(entity = Customer.class, column = "address", condition = "this.name = id")
    private String address;
    /**
     * 负责人 关联信息
     */
    @BindQuery(entity = Customer.class, column = "principal", condition = "this.name = id")
    private String user;
    /**
     * 所属部门 关联信息
     */
    @BindQuery(entity = Customer.class, column = "dept", condition = "this.name = id")
    private String dept;
    /**
     * 创建时间
     */
    @BindQuery(comparison = Comparison.GE)
    private LocalDateTime createTime;
    /**
     * 创建时间 起始
     */
    @BindQuery(comparison = Comparison.GE, column = "create_time")
    private LocalDate createTimeBegin;

    /**
     * 创建时间 截止
     */
    @BindQuery(comparison = Comparison.LT, column = "create_time")
    private LocalDate createTimeEnd;
    /**
     * 更新时间
     */
    @BindQuery(comparison = Comparison.GE)
    private LocalDateTime updateTime;
    /**
     * 更新时间 起始
     */
    @BindQuery(comparison = Comparison.GE, column = "update_time")
    private LocalDate updateTimeBegin;

    /**
     * 更新时间 截止
     */
    @BindQuery(comparison = Comparison.LT, column = "update_time")
    private LocalDate updateTimeEnd;

    public LocalDate getCreateTimeEnd() {
        if (getCreateTime() != null) {
            return getCreateTime().plusDays(1).toLocalDate();
        }
        if (createTimeEnd != null) {
            return createTimeEnd.plusDays(1);
        }
        return null;
    }

    public LocalDate getUpdateTimeEnd() {
        if (getUpdateTime() != null) {
            return getUpdateTime().plusDays(1).toLocalDate();
        }
        if (updateTimeEnd != null) {
            return updateTimeEnd.plusDays(1);
        }
        return null;
    }

}